71B - Progress Bar - CodeForces Solution


implementation math *1300

Please click on ads to support us..

Python Code:

from math import ceil, remainder

def capture_numbers():
    line = input()
    return [int(number) for number in line.split(' ')]

elements, max, percentage = capture_numbers()

step = 100 / elements

values = [0 for index in range(elements)]

fulls = int(percentage / step)

remaining = percentage - (fulls * step)

pwm = int(remaining * max / step)

for index in range(fulls):
    values[index] = max

if remaining != 0:
    values[fulls] = pwm


print(' '.join([str(value) for value in values]))

C++ Code:

#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<stack>
#include<iterator>
#include<deque>
#include<queue>
#include<unordered_set>
#include<set>
using namespace std;
using ll =  long long;
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define MANEX main
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vp = vector<pii>;
const ll INF = 1e18 + 10;
const int MAX = 1e5 + 10;

void solve() {
    int n, k, t;
    scanf("%d%d%d", &n, &k, &t);
    int canHave = (n * k * t) / 100;
    for(int i = 0; i < n; i++) {
        if(canHave > k) printf("%d ", k);
        else if(canHave > 0) printf("%d ", canHave);
        else printf("%d ", 0);
        canHave -= k;
    }
    printf("\n");
}  

int MANEX() {    
    solve();
}























Comments

Submit
0 Comments
More Questions

1647D - Madoka and the Best School in Russia
1208A - XORinacci
1539B - Love Song
22B - Bargaining Table
1490B - Balanced Remainders
264A - Escape from Stones
1506A - Strange Table
456A - Laptops
855B - Marvolo Gaunt's Ring
1454A - Special Permutation
1359A - Berland Poker
459A - Pashmak and Garden
1327B - Princesses and Princes
1450F - The Struggling Contestant
1399B - Gifts Fixing
1138A - Sushi for Two
982C - Cut 'em all
931A - Friends Meeting
1594A - Consecutive Sum Riddle
1466A - Bovine Dilemma
454A - Little Pony and Crystal Mine
2A - Winner
1622B - Berland Music
1139B - Chocolates
1371A - Magical Sticks
1253A - Single Push
706B - Interesting drink
1265A - Beautiful String
214A - System of Equations
287A - IQ Test